package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbItemMapper;
import com.dongdongshop.pojo.TbItem;
import com.dongdongshop.pojo.TbItemExample;
import com.dongdongshop.service.ItemService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
@DubboService
public class ItemServiceImpl implements ItemService {

    @Resource
    private TbItemMapper tm;

    @Override
    public List<TbItem> selectItemListByGoodsId(Long goodsId) {
        TbItemExample example = new TbItemExample();
        example.createCriteria().andGoodsIdEqualTo(goodsId);
        return tm.selectByExample(example);
    }

    @Override
    public List<TbItem> selectItemList() {
        return tm.selectByExample(null);
    }

    @Override
    public void updateStockCount(TbItem item) {
        tm.updateByPrimaryKeySelective(item);
    }

    @Override
    public TbItem selectItemById(Long itemId) {
        return tm.selectByPrimaryKey(itemId);
    }
}
